// run: $exec < input
#include <iostream>
#include <cstdio>
#include <algorithm>

#define INF 1000001
int const maxn = 107;
int len[maxn * maxn];

int a[maxn * maxn],b[maxn * maxn];
int A[maxn * maxn];
int n, t;

int find(int r,int l,int p)
{
	if( r == l ) return r;
	int mid = ((r+l)>>1)+(r+l)%2;
	if(b[mid] > p) return find(r,mid-1,p);
	else return find(mid,l,p);
}

int main()
{
	std::cin >> n >> t;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		b[i] = INF;
	}
	for (int i = n + 1; i <= n * n; i++) {
		a[i] = a[i - n];
		b[i] = INF;
	}
	b[1]=a[1];
	int ans=1, x;
	len[1] = 1;

	A[0]=-INF;
	A[1]=a[1];
	for(int i=2;i<=n * n;i++){
		int j=std::lower_bound(A+1,A+ans+1,a[i])-A;
		if(j>ans)ans=j;
		len[i] = j;
		A[j]=a[i];
	}
	/*
	for(int i=2;i<=n * n;i++) {
		x=find(0,ans,a[i]);
		x++;
		len[i] = x;
		b[x]=b[x]>a[i]?a[i]:b[x];
		ans=ans<x?x:ans;
	}
	*/

	int out = 0;
	for (int i = 1; i <= n * n; i++) {
		if (int((i-1) / n) >= t) break;
		int res = t - int((i-1) / n) - 1;
		out = std::max(out, len[i] + res);
	}

	/*
	   for (int i = 1; i <= n * n; i++)
	   std::cout << a[i] << ' ';
	   std::cout << '\n';
	   for (int i = 1; i <= n * n; i++)
	   std::cout << len[i] << ' ';
	   std::cout << '\n';
	   */

	std::cout << out << '\n';
}

